package es.pawer.web.checklists.data;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;


public class ChecklistDAO {
	
	
	private static final String checkListClass=Checklist.class.getName();
	
	private static final PersistenceManager manager= PersistenceMFactory.getPM();
	
	
	public static Checklist getCheckList(int pos) {
		Query query=manager.newQuery("SELECT FROM "+checkListClass+" WHERE id= parameter");
		query.declareParameters("int parameter");
		return (Checklist) query.execute(pos);
	}

	@SuppressWarnings("unchecked")
	public static List<String> getAllCheckListNames() {
		Query query=manager.newQuery("SELECT name FROM "+checkListClass+" ORDER BY name");
		return (List<String>) query.execute();
	}
	
	public static Checklist insertChecklist(Checklist cl) {
		return manager.makePersistent(cl);
	}
}
